import type * as User from "./type"
import { request } from "@/http/axios"

/** 增改 */
export function saveUser(data: User.UserData) {
  return request({
    url: "system/user/save",
    method: "post",
    data
  })
}

/** 删 */
export function deleteUser(id: number) {
  return request({
    url: `system/user/delete/${id}`,
    method: "post"
  })
}

/** 查 */
export function queryUserPage(data: User.UserQueryData) {
  return request<User.UserResponseData>({
    url: "system/user/page",
    method: "post",
    data
  })
}

/**
 * 名称是否重复
 */
export function checkUsername(id: number | null, username: string) {
  return request({
    url: `system/user/check`,
    method: "get",
    data: {
      id,
      column: "username",
      value: username
    }
  })
}
/**
 * 修改用户状态
 */
export function updateUserEnable(id: number, enable: boolean) {
  return request({
    url: `system/user/updateEnable/${id}`,
    method: "post",
    params: {
      enable
    }
  })
}
/**
 * 设置用户密码
 */

export function updatePassword(id: number, password: string) {
  return request({
    url: `system/user/updatePassword/${id}`,
    method: "post",
    params: {
      password
    }
  })
}
